package com.fly.caihong.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fly.caihong.R;
import com.fly.caihong.model.MallGoodsItem;
import com.fly.caihong.utils.ApUtils;
import com.fly.caihong.utils.GlideUtils;

import java.util.ArrayList;
import java.util.List;


public class MallCategoryAdapter extends BaseQuickAdapter<MallGoodsItem, BaseViewHolder> {
    public MallCategoryAdapter(List<MallGoodsItem> dataList) {
        super(R.layout.layout_mall_category_item, dataList == null ? new ArrayList<MallGoodsItem>() : dataList);
    }

    @Override
    protected void convert(BaseViewHolder helper, MallGoodsItem item) {
        ImageView ivImage = helper.getView(R.id.iv_image);
        GlideUtils.loadRoundImage(ApUtils.getApp(), ivImage, item.getImage());
        helper.setText(R.id.tv_name, item.getGoodsName()).setText(R.id.tv_mall, item.getShopName()).setText(R.id.tv_price, item.getPrice())
                .setText(R.id.tv_detail, String.format("%s付款    %s", item.getBuyCount(), item.getCity()))
                .setVisible(R.id.tv_new, item.isNew()).setVisible(R.id.tv_by, item.isBy());
    }
}
